import hashlib
import base64
from idlelib.iomenu import encoding

from Tools.scripts.generate_opcode_h import header
from numpy.core.defchararray import rpartition

from lib.print_sql import response_json


#MD5加密
def MD5(st):
    res = hashlib.md5(str(st).encode())
    return res.hexdigest()


#base64加密解密
def Base64en(st):
    return base64.b64encode(str(st).encode()).decode()

def Base64de(st):
    return base64.b64decode(st.encode()).decode()

# print(Base64en("213"))
# print(Base64de('MjEz'))

#百度翻译
import requests
from jsonpath import jsonpath

def translate(content):
    url = "https://fanyi.baidu.com/sug"
    header = {
    "User-Agent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36"
    }
    para = {
    "kw": content
    }
    res = requests.post(url,headers=header,data=para)
    # print(res.json())
    result = jsonpath(res.json(),'$..v')
    print(f'翻译结果为：{result}')

# translate("翻译")